package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonPage;
import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.request.PayConfigRequest;
import com.ytjj.qmyx.admin.service.PayConfigService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信支付配置页
 */
@RestController
@RequestMapping("/payConfig")
public class PayConfigController {
    @Autowired
    private PayConfigService payConfigService;

    /**
     * 查询列表
     * @param payConfigRequest
     * @return
     */
    @RequiresPermissions("payConfig:list")
    @PostMapping("/list")
    public CommonResult list(@RequestBody PayConfigRequest payConfigRequest){
        CommonPage pageList = payConfigService.list(payConfigRequest);
        return CommonResult.success(pageList);
    }

    /**
     * 编辑列表
     * @param payConfigRequest
     * @return
     */
    @RequiresPermissions("payConfig:updateById")
    @PostMapping("/updateById")
    public CommonResult updateById(@RequestBody PayConfigRequest payConfigRequest){
        int count = payConfigService.updateById(payConfigRequest);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }
}
